import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;

public class Test {
    public static void main(String[] args) {
        BigDecimal a =new BigDecimal("1.35");
        BigDecimal b = new BigDecimal("3.22");

        /*BigDecimal addRet = a.add(b);
        System.out.println(addRet);

        BigDecimal subRet = a.subtract(b);
        System.out.println(subRet);

        BigDecimal mulRet = a.multiply(b);
        System.out.println(mulRet);*/

        /*BigDecimal divRet = a.divide(b);
        System.out.println(divRet);*/

//        BigDecimal divRet = a.divide(b, 4, RoundingMode.HALF_UP);
//        System.out.println(divRet);

//        BigDecimal divRet = a.divide(b, new MathContext(4, RoundingMode.HALF_UP));
//        System.out.println(divRet);
    }
    public static void main2(String[] args) {
        System.out.println(0.1+0.2);
        BigDecimal bigDecimal1 = new BigDecimal("0.1");
        BigDecimal bigDecimal2 = new BigDecimal("0.2");

        BigDecimal ret = bigDecimal1.add(bigDecimal2);
        System.out.println(ret);
    }
    public static void main1(String[] args) {
        double d = 12.5;

        BigDecimal bigDecimal = new BigDecimal(1.99);

        System.out.println(bigDecimal);


        BigDecimal bigDecimal2 = new BigDecimal("1.99");//常用字符串
        System.out.println(bigDecimal2);
    }
}
